﻿//------------------------------------------------------------------
// System Name:    NRemedy
// Component:      NRemedy
// Create by:      Parker Zhou (parkerz@wicresoft.com)
// Create Date:    2012-04-16
//------------------------------------------------------------------
using System;
using BMC.ARSystem;

namespace Wicresoft.EKA.NRemedy.CodeGenerate
{
    public class ARTypeMap
    {
        /// <summary>
        /// type mapping for NETConvertToAR in UnBind
        /// </summary>
        /// <param name="type">ar type</param>
        /// <returns>NET Type</returns>
        public static Type ARTypeToNETType(ARType type)
        {
            switch (type)
            {
                case ARType.IntegerField:
                    return typeof(Int32);
                case ARType.RealField:
                    return typeof(Double);
                case ARType.CharacterField:
                    return typeof(String);
                case ARType.DiaryField:         //API accept string when set
                    return typeof(String);
                case ARType.SelectionField:     //API accept int when set
                    return typeof(Int32);
                case ARType.DateTimeField:
                    return typeof(DateTime);
                case ARType.DecimalField:
                    return typeof(Decimal);
                case ARType.AttachmentField:
                    return typeof(Attachment);
                case ARType.CurrencyField:
                    return typeof(CurrencyValue);
                case ARType.DateOnlyField:
                    return typeof(DateValue);
                case ARType.TimeOnlyField:
                    return typeof(TimeOfDayValue);
                default:
                    throw new ArgumentOutOfRangeException("type");
            }
        }

        /// <summary>
        /// type mapping for ARConvertToNET in Bind
        /// </summary>
        /// <param name="type">ar type</param>
        /// <returns>NET Type</returns>
        public static Type NETTypeToARType(ARType type)
        {
            switch (type)
            {
                case ARType.IntegerField:
                    return typeof(Int32);
                case ARType.RealField:
                    return typeof(Double);
                case ARType.CharacterField:
                    return typeof(String);
                case ARType.DiaryField:
                    return typeof(DiaryList);
                case ARType.SelectionField:
                    return typeof(Int32);
                case ARType.DateTimeField:
                    return typeof(DateTime);
                case ARType.DecimalField:
                    return typeof(Decimal);
                case ARType.AttachmentField:
                    return typeof(Attachment);
                case ARType.CurrencyField:
                    return typeof(CurrencyValue);
                case ARType.DateOnlyField:
                    return typeof(DateValue);
                case ARType.TimeOnlyField:
                    return typeof(TimeOfDayValue);
                default:
                    throw new ArgumentOutOfRangeException("type");
            }
        }

       
    }
}
